//
//  Utils.h
//  ChatDemo-UI2.0
//
//  Created by li.guibin on 15/11/30.
//  Copyright © 2015年 li.guibin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@interface Utils : NSObject

#pragma -- GET 网络请求

+(BOOL)get:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;
+(BOOL)noHUD_get:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;

+(BOOL)noIndiGet:(NSString *)urlStr  parameters:(NSDictionary *)parameters success:( void(^)(NSInteger recode, id jsonObject) ) success failure:( void(^)(NSInteger recode, NSError *error) ) failure;
+(BOOL)getAllClass:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id))success failure:(void (^)(NSInteger recode, NSError *))failure;
/*17.02.06 zz 增加判断请求类型的get请求，用于判断对于初次进入列表页面与上下拉请求的判断，因为这两种方式所对应的hud不同，1代表为刚进入主动发起的请求，2代表为主动上下拉请求**/
+(BOOL)requestTypeGet:(NSString *)urlStr type:(int)type parameters:(NSDictionary *)parameters success:( void(^)(NSInteger recode, id jsonObject) ) success failure:( void(^)(NSInteger recode, NSError *error) ) failure;

+(BOOL)post:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;
#pragma mark -Jave接口

+(BOOL)Java_get:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;

+(BOOL)noHUD_Java_get:(NSString *)urlStr parameters:(NSDictionary *)parameters success:(void (^)(NSInteger recode, id jsonObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;

#pragma mark -旷世接口
/**旷世上传底片*/
+ (BOOL)uploadImage:(NSString *)url parameters:(NSMutableDictionary *)parameters image:(UIImage *)image success:(void (^)(AFHTTPRequestSerializer * option, id responjson))success failure:(void (^)(AFHTTPRequestSerializer * option, NSError * error))failure;

+ (void)loginKuangshi:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^) (AFHTTPResponseSerializer *option,id responjson))success failure:(void (^)(AFHTTPResponseSerializer *option,NSError *error))failure;


//获取个人信息
+ (void)getInfoByid:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^)(NSURLSessionDataTask *task,id responjson))success failure:(void (^)(NSURLSessionDataTask *task,NSError *error))failure;

//修改旷视个人信息接口
+ (void)editInfo:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^)(NSURLSessionDataTask *task,id jsonobject))success failure:(void (^)(NSURLSessionDataTask *task,NSError *error))failure;

#pragma mark -依图接口
/**依图登陆接口*/
+ (void)loginYiTu:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^)(AFHTTPResponseSerializer *, id))success failure:(void (^)(AFHTTPResponseSerializer *, NSError *))failure;
/**上传图片*/
+ (BOOL)yiTuUploadImage:(NSString *)url parameters:(NSMutableDictionary *)parameters image:(UIImage *)image success:(void (^)(AFHTTPRequestSerializer * option, id responjson))success failure:(void (^)(AFHTTPRequestSerializer * option, NSError * error))failure;

//修改依图对应个人信息
+ (void)editYiTuInfo:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure;
//获取依图个人信息
+ (void)getYiTuInfoByid:(NSString *)url parameters:(NSMutableDictionary *)parameters success:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure;

+(void)submitImageToWebService:(NSString *)severURL SOAPActionSring:(NSString *)SOAPString postValue:(NSString *)postValue success:(void (^)(NSInteger recode, id responseObject))success failure:(void (^)(NSInteger recode, NSError *error))failure;



#pragma -- PACKAGE PARAMETERS
+ (NSMutableDictionary *)completeImageSubmitParameterWith:(NSMutableDictionary *)originalParameter;
+ (NSMutableDictionary *)completeParameterWith:(NSMutableDictionary *)originalParameter;
+ (NSString *)getXMLStringWithParameter:(NSMutableDictionary *)origianlDict;
#pragma -- GET SIGN VALUE
+ (NSString *)urlWithSignValue:(NSDictionary*)dict;
//#pragma -- PERSONEAL IMFORMATION SOTRE&ACQUIRE
//+ (BOOL)personalImformationSaveWtih:(NSDictionary *)imformation;
+ (NSDictionary *)acquirePersonalImformationFromMemoryWithPersonID:(NSString *)personalID;
#pragma -- 转码
+ (NSString*)URLencode:(NSString *)originalString stringEncoding:(NSStringEncoding)stringEncoding;
+(NSString *) encodeUrlStr:(NSString *)sourceString;
#pragma -- XMLParse
+ (id)parseXMLWithResposeData:(NSData *)resposeData;

+ (void)alertViewWithMessage:(NSString *)message;
+ (NSString *)MD5EncryptWith:(NSString *)originalStr;
+ (NSString *)getStringByDate:(NSDate *)date;
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
+ (UIColor *)colorWithHexString:(NSString *)color;
+ (NSUInteger)transformStringToNsinterger:(NSString *)dateStr;
+(void)hasMobile:(id)delegate andFunc:(NSString *)func;
/**
 *  压缩图片
 *  @param image   图片
 *  @return 压缩好的图片
 */
+(UIImage *)imageWithImage:(UIImage *)image;

/**
 *  用于判断字符串中是否含有表情
 *
 *  @param string 传入的字符串
 *
 *  @return bool类型
 */
+ (BOOL)stringContainsEmoji:(NSString *)string;

/**
 *  返回一段字符串的高度
 *
 *  @param str 传入的字符串
 *
 *  @return 字符串的size
 */
+(CGSize )labelSizeWithStr:(NSString *)str andWidth:(CGFloat)width andFont:(CGFloat)font;
+(CGFloat)resizeContentLabelHeightWithString:(NSString *)str andLineSpacing:(CGFloat)space andFont:(UIFont *)font andMaxWidth:(CGFloat)maxWidth;

///*
// *  计算字符串尺寸
// */
//+ (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize lineBreakMode:(NSLineBreakMode)lineBreakMode;

/**
 *  修改时间
 *
 *  @param str 传入时间
 *
 *  @return 1 代表今天 2 代表昨天前 3 代表跨年
 */
+(NSString *)getProperDataStringWithString:(NSString *)str;

/**
 *  检查当前网络环境状态
 *
 */
+(void)checkNetStateWithBlock:(void(^)(int type))block;
/**
 *  云盘时间显示
 *
 *  @param str <#str description#>
 *
 *  @return <#return value description#>
 */
+(NSString *)getDataStringWithString:(NSString *)str;

/**
    当天只显示时分，隔天显示月日时分，跨年显示年月日时分
 */
+(NSString *)getDataStringWithoutSecondString:(NSString *)str;
/**
 *  判断状态，从后台返回前台时候调用下
 */
+(void)judgeState;

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

+(void)hideHUD;
+(void)showHUD;
/*
 *获取当前视图控制器
 */
+(UIViewController *)getCurrentVC;
//获取当前时间
+ (NSString *)getCurrentTime;

//判断是否为空字符串
+ (BOOL) isBlankString:(NSString *)string;
/*
 * @Sylar
 *
 * 16进制字符串生成颜色对象.   e.g #FF0011 = (255,0,17)
 */
UIColor* colorFromHex(NSString * hexString);

/*
 * @Sylar
 *
 * 16进制字符串生成颜色对象,alpha 透明度alpha < 1.0
 */
UIColor* colorFromHexAndAlpha(NSString * hexString,CGFloat alpha);

/**清理webview缓存,退出登录时候手动清理一下webview缓存*/
+ (void)clearWebViewCache;

+(UIColor *)stringToColor: (NSString *) stringToConvert;

/*
 * @Sylar
 *
 * 关键字搜索
 */
+(NSMutableArray *)getRangeStr:(NSString *)text findText:(NSString *)findText;

+(void)resaePersonadataWithLogo:(NSString *)url;
+ (NSString*)dictionaryToJson:(NSDictionary *)dic;

+ (NSString*)weekdayStringFromDate:(NSDate*)inputDate;

+(void)resaePersonadataWithBacePic:(NSString *)imageId;
@end
